package com.crrcdt.thread;

/**
 * @author lj on 2020/11/18.
 * @version 1.0
 */
public class MyTheard implements Runnable {
    private String name;//线程名字

    public MyTheard(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i <10 ; i++) {
            System.out.println(name + i+" 正在运行");
        }

    }

    public static void main(String[] args) {
        final MyTheard myTheardA = new MyTheard("线程A");
        new Thread(myTheardA).start();
        final MyTheard myTheardB = new MyTheard("线程B");
        new Thread(myTheardB).start();
    }
}
/**
 * 总结： 多用实现runnable接口 因为继承只能单继承
 * 实现runnable接口 其实也就是在new THread()重载实现而已 就是这个Thread(Runnable target)
 * Thread 类也是 Runnable 接口的子类
 */
